Module WebmasterTools::Sitemappable::ClassMethods
In: lib/webmaster_tools/sitemappable.rb

Methods

Included Modules

Sitemappable::InstanceMethods

Attributes

sitemap_changefreq  [RW] 
sitemap_host  [RW] 
sitemap_index_path  [RW] 
sitemap_lastmod_field  [RW] 
sitemap_path  [RW] 
sitemap_priority  [RW] 
sitemap_protocol  [RW] 

Public Instance methods

Options

  • path: Defaults to the underscore, pluralized name - Author => /authors
  • index_path: Defaults to the underscore and _sitemap.xml, pluralized name - Author => /authors_sitemap.xml - this way it‘s at the root level
  • host: Defaults to localhost:3000
  • protocol: Defaults to http://
  • priority: A value from 0.0 - 1.0. Defaults to 0.5
  • changefreq: Defualts to "daily". Must be one of
      always
      hourly
      daily
      weekly
      monthly
      yearly
      never
    
  • lastmod_field: The field in the database, or method on the model, that holds the last modified date. Defaults to "updated_at"

[Source]

    # File lib/webmaster_tools/sitemappable.rb, line 30
30:       def sitemappable(options = {})
31:         WebmasterTools::Sitemaps.model_sitemaps << name.downcase.to_sym unless WebmasterTools::Sitemaps.model_sitemaps.include?(name.downcase.to_sym)
32: 
33:         class << self
34:           attr_accessor :sitemap_changefreq, :sitemap_priority, :sitemap_path, :sitemap_lastmod_field, :sitemap_host, :sitemap_protocol, :sitemap_index_path
35:         end
36: 
37:         @sitemap_path           = options[:path]          || "/#{name.underscore.pluralize}"
38:         @sitemap_index_path     = options[:index_path]    || "/#{name.underscore.pluralize}_sitemap.xml"
39:         @sitemap_changefreq     = options[:changefreq]    || WebmasterTools::Sitemaps::Defaults.changefreq    || "weekly"
40:         @sitemap_priority       = options[:priority]      || WebmasterTools::Sitemaps::Defaults.priority      || "0.5"
41:         @sitemap_lastmod_field  = options[:lastmod_field] || WebmasterTools::Sitemaps::Defaults.lastmod_field || :updated_at
42:         @sitemap_host           = options[:host]          || WebmasterTools::Sitemaps::Defaults.host          || "localhost:3000"
43:         @sitemap_protocol       = options[:protocol]      || WebmasterTools::Sitemaps::Defaults.protocol      || "http://"
44: 
45:         include Sitemappable::InstanceMethods
46:         extend  Sitemappable::SingletonMethods
47:       end

This makes it easy to check if the class has the sitemappable mixin

[Source]

    # File lib/webmaster_tools/sitemappable.rb, line 50
50:       def sitemappable?
51:         true
52:       end

[Validate]